<?php
/**
 * Well Framework
 * 
 * Database layer based on PDO usage
 * 
 * @todo move out connection settings to config file.
 * 
 * @package     Well
 * 
 * @author valerii lazarevych <valeriy.fremar@gmail.com>
 * @copyright Fremar ltd.
 */

class DbLayer
{
    /**
     * Database type
     * Default value  'mysql'
     * 
     * @var string $db_type
     */
    private     $db_type    =   'mysql';
    
    /**
     * Url address of db server
     * @var string $db_url
     */
    private     $db_host     =   'localhost';
    
    /**
     * Database name
     * @var string $db_name
     */
    private     $db_name    =   'boatm';
    
    /**
     * Database user name
     * @var string $username
     */
    private     $username   =   'root';
    
    /**     
     * @todo hide implementation of this field
     * 
     * @var string $passwd
     */
    private     $passwd     =   '';
    
    /**
     * Database connection Options 
     * @var array $options
     */
    private     $options    =   null;
    
    /**
     * PDO object connected to database
     * @var PDO $pdo
     */
    public      $pdo        =   null;
    
    /**
     * DbLayer Instance
     * @var DbLayer $instance
     */
    private static $instance= null;
                   
        

    public function __construct() 
    {
        $this->pdo  =  new PDO( $this->db_type.':dbname='.$this->db_name
                                .';host='.$this->db_host, $this->username, $this->passwd);                        
    }
			
    public static function getDbOperator()
    {								        	
        $dbOperator =   new self();
        
        return $dbOperator->pdo;
    }

} 
?>